const mongoose = require("mongoose");
const { mongo } = require("./env");
const { log } = require("./utils");

const db = mongoose.connection;

db.on("error", err => {
	log("red", "mongo 连接出错: " + err);
});

db.on("disconnected", () => {
	log("red", "mongo 连接已断开!");
});

db.on("connected", () => {
	log("blue", "mongo 连接已连接!");
});

mongoose.connect(mongo.url, mongo.params);
